<?php


namespace app\video\controller;

use think\Request;
use app\video\model\VideoModel;

class Video
{
    public function getHomeAllVideoList(){
        $msg = VideoModel::getHomeAllVideoList();
        $data = [
            'code' => 200,
            'msg' => $msg
        ];
        return json($data);
    }

    public function getAllTypeList(){
        $msg = VideoModel::getAllTypeList();
        $data = [
            'code' => 200,
            'msg' => $msg
        ];
        return json($data);
    }

    public function getTypeVideoByID(){
        $request = Request::instance();
        $pram = $request->post();
        $data = array();
        if($pram['id'] == null || $pram['page'] == null || $pram['num'] == null){
            $data['code'] = 401;
            $data['msg'] = '请将参数填写完整';
            return json($data);
        }
        $msg = VideoModel::getTypeVideoByID($pram);
        $data = [
            'code' => 200,
            'count' => $msg['count'],
            'msg' => $msg['msg']
        ];
        return json($data);
    }

    public function getVideoMsg(){
        $request = Request::instance();
        $pram = $request->post();
        $data = array();
        if($pram['id'] == null){
            $data['code'] = 401;
            $data['msg'] = 'id为空';
            return json($data);
        }
        $msg = VideoModel::getVideoMsg($pram['id']);
        $data = [
            'code' => 200,
            'msg' => $msg
        ];
        return json($data);
    }

    public function getVideoByName(){
        $request = Request::instance();
        $pram = $request->post();
        $data = array();
        if($pram['name'] == null || $pram['page'] == null || $pram['num'] == null){
            $data['code'] = 401;
            $data['msg'] = '请将参数填写完整';
            return json($data);
        }
        $msg = VideoModel::getVideoByName($pram);
        $data = [
            'code' => 200,
            'count' => $msg['count'],
            'msg' => $msg['msg']
        ];
        return json($data);
    }
}